/*qa82Pm79QnBpcraP5omSXMe/JCGXYnSakxAoJ6olHSiLXW/8ryLdnxqAVC7MXuuV*/
/**
 * 公共方法
 */
import {cardCache} from 'nc-lightapp-front';
import ampub from 'ampub';
const { utils} = ampub;
const {  msgUtils, listUtils } = utils;
const { MsgConst, showMessage, showErrorMessageByRes} = msgUtils;
const {setListValue} = listUtils;

import constants from '../../constants';
import {setBatchBtnsEnable} from "./rowSelected";

const tableId = constants.AREA.LIST.GRID_AREA;
const assetDataSource = constants.assetDataSource;

//列表态——列表查询回调处理
const listQueryBackHandler = {
    success: (props, res, scene) => {
        let {success, data} = res;
        if (success) {
            setListValue.call(this, props, res, tableId, scene);
            setBatchBtnsEnable.call(this, props, tableId);

            //取出 pk2ClientKeyMap 并存到缓存中
            let {success, data} = res;
            if(success && data) {
                cardCache.setDefData(constants.pk2ClientKeyMap, assetDataSource, JSON.parse(data.userjson));
            }

        } else {
            props.table.setAllTableData(tableId, {rows: []});
            /*国际化处理：未查询出符合条件的数据*/
            showMessage(props, { type: MsgConst.Type.QueryNoData });
        }
    },
    error: (props, res) => {
        showErrorMessageByRes(props, res);
    }
};

export {
    listQueryBackHandler
}
/*qa82Pm79QnBpcraP5omSXMe/JCGXYnSakxAoJ6olHSiLXW/8ryLdnxqAVC7MXuuV*/